# _*_ coding:utf-8 _*_
from celery import shared_task
from django.core.management import call_command
import logging

logger = logging.getLogger(__name__)

@shared_task
def run_scrapper_command():
    """定时任务：直接调用Django管理命令"""
    try:
        logger.info("开始执行Amazon数据爬取任务")
        # 直接调用你已经写好的管理命令
        call_command("scrapper_amazon_data")
        logger.info("Amazon数据爬取任务执行成功")
        return "Amazon数据爬取任务执行成功"
    except Exception as e:
        logger.error(f"Amazon数据爬取任务执行失败: {str(e)}")
        return f"Amazon数据爬取任务执行失败: {str(e)}"
